using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Champ
{
    //Stores Item data like effects and textures
    public class Item : Sprite
    {

        // Item name
        public String name = "";

        // Item power or level modifier
        public int lvlMod = 0;

        // Type of item
        // 0 = level, 1 = attack, 2 = defense, 3 = magic
        public int type = 0;

        // To place on inventory screen
        // owner is player 1, 2, 3, or 4
        // pos is the position in the inventory (location in the array)
        public int owner = 0;
        public int pos = 0;

        // Is the item equiped to the player?
        // set to false so that all of monsters loot isn't immediately equiped.
        public bool equiped = false;

        // To adjust items position on the screen.
        public int xAdj = 0;
        public int yAdj = 0;


        // Display information for inventory adjustment
        // Takes in grid coordinate for inventory screen and converts to pixel location
        public void itemDisplayDataIS(Rectangle relativeScreenSize, Rectangle normalScreenSize)
        {

            if (owner == 1)
            {
                // Located in top left corner.
                if (pos == 0)
                {
                    xAdj = 50;
                    yAdj = 50;
                }
                else if(pos == 1)
                {
                    xAdj = 200;
                    yAdj = 50;
                }
                else if(pos == 2)
                {
                    xAdj = 350;
                    yAdj = 50;
                }
                else if(pos == 3)
                {
                    xAdj = 50;
                    yAdj = 200;
                }
                else if(pos == 4)
                {
                    xAdj = 200;
                    yAdj = 200;
                }
                else if(pos == 5)
                {
                    xAdj = 350;
                    yAdj = 200;
                }

            }
            else if (owner == 2)
            {
                // Top right corner
                if (pos == 0)
                {
                    xAdj = 670;
                    yAdj = 50;
                }
                else if (pos == 1)
                {
                    xAdj = 820;
                    yAdj = 50;
                }
                else if (pos == 2)
                {
                    xAdj = 970;
                    yAdj = 50;
                }
                else if (pos == 3)
                {
                    xAdj = 670;
                    yAdj = 200;
                }
                else if (pos == 4)
                {
                    xAdj = 820;
                    yAdj = 200;
                }
                else if (pos == 5)
                {
                    xAdj = 970;
                    yAdj = 200;
                }

            }
            else if (owner == 3)
            {
                // Bottom left corner of the screen.
                if (pos == 0)
                {
                    xAdj = 50;
                    yAdj = 540;
                }
                else if (pos == 1)
                {
                    xAdj = 200;
                    yAdj = 540;
                }
                else if (pos == 2)
                {
                    xAdj = 350;
                    yAdj = 540;
                }
                else if (pos == 3)
                {
                    xAdj = 50;
                    yAdj = 690;
                }
                else if (pos == 4)
                {
                    xAdj = 200;
                    yAdj = 690;
                }
                else if (pos == 5)
                {
                    xAdj = 350;
                    yAdj = 690;
                }

            }
            else if (owner == 4)
            {
                if (pos == 0)
                {
                    xAdj = 670;
                    yAdj = 540;
                }
                else if (pos == 1)
                {
                    xAdj = 820;
                    yAdj = 540;
                }
                else if (pos == 2)
                {
                    xAdj = 970;
                    yAdj = 540;
                }
                else if (pos == 3)
                {
                    xAdj = 670;
                    yAdj = 690;
                }
                else if (pos == 4)
                {
                    xAdj = 820;
                    yAdj = 690;
                }
                else if (pos == 5)
                {
                    xAdj = 970;
                    yAdj = 690;
                }
            }
            this.renderingRect.X = relativeScreenSize.X + xAdj;
            this.renderingRect.Y = relativeScreenSize.Y + yAdj;
            this.renderingRect.Width = (normalScreenSize.Width / relativeScreenSize.Width)*100;
            this.renderingRect.Height = (normalScreenSize.Height / relativeScreenSize.Height)*100;
        }

        // Display information for loot distribution
        public void itemDisplayDataLD(Rectangle relativeScreenSize, Rectangle normalScreenSize, int order)
        {
            xAdj = 500; //Since they're lined up vertically.
            if (order == 0)
            {
                yAdj = 100;
            }
            else if (order == 1)
            {
                yAdj = 250;
            }
            else if (order == 2)
            {
                yAdj = 400;
            }
            else if (order == 3)
            {
                yAdj = 550;
            }
            else if (order == 4)
            {
                yAdj = 700;
            }

            this.renderingRect.X = relativeScreenSize.X + xAdj;
            this.renderingRect.Y = relativeScreenSize.Y + yAdj;
            this.renderingRect.Width = (normalScreenSize.Width / relativeScreenSize.Width) * 100;
            this.renderingRect.Height = (normalScreenSize.Height / relativeScreenSize.Height) * 100;
        }
    }
}